package pyip.lib.javalearn.locale;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * @author yepeng
 * @date 2015年8月26日
 */
public class ResourceBundleDemo {

    public static void main(String[] args) {
        // 如果找不到Locale对应的文件(resourceBundleDemo_en.properties), 会加载Default Local对应的文件(resourceBundleDemo_zh_CN.properties)
        // 没有则继续加载resourceBundleDemo_zh.properties, resourceBundleDemo.properties
        // 都没有则抛出异常
        ResourceBundle enBundle = ResourceBundle.getBundle("resourceBundleDemo", new Locale("en"));
        System.out.println("locale en: " + enBundle.getString("name"));

        ResourceBundle caBundle = ResourceBundle.getBundle("resourceBundleDemo", new Locale("en", "ca"));
        System.out.println("locale en_CA: " + caBundle.getString("name"));

        ResourceBundle zhBundle = ResourceBundle.getBundle("resourceBundleDemo", new Locale("zh", "CN"));
        System.out.println("locale zh_CN: " + zhBundle.getString("name"));

    }
}
